
<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;

    $forder_upload = "avatarxs"; 
    $link_avatar = Yii::app()->params["urlImages"]."upload.php?forder_upload=".$forder_upload;
    //var_dump($file_location);die;
    $link_url = Yii::app()->params["urlImages"]."upload_base.php?forder_upload=".$forder_upload; 
    //var_dump($link_avatar);
?>

<!--<link rel="stylesheet" href="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/css/swfupload.css" type="text/css" />-->
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/swfupload.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/swfupload.queue.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/fileprogress.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->params['urlImages']; ?>lib_upload/js/handlers.js"></script>
<script type="text/javascript">

    window.onload = function() {
        var configUploadData = {
            flash_url:"<?php echo Yii::app()->params["urlImages"];?>lib_upload/js/swfupload.swf",
            create_date:0,
            button_image_url:"<?php echo Yii::app()->params["urlImages"];?>lib_upload/images/buttonUpload3.png",
            upload_url: "<?php echo $link_avatar;?>", 
            file_types: "*.jpg;*.jpeg;*.png;*.gif", 
            file_upload_limit : 20, 
            file_queue_limit : 1, 
            debug : false
        }
        configUpload(configUploadData);         
    };

    function uploadResponse(serverData){  
        try {
            var response = $.parseJSON(serverData); 
            if(response.code==404){
                alert(response.message);return false;
            }  
            var filename = response.filename;    
            var path = response.path;
            var message = response.message;
            var code = response.code;
            var extension = response.extension;
            var filesize = response.filesize;
            $("#picture").val(filename);
            $("#show_pic").html('<img src="<?php echo Yii::app()->params["urlAvatar"].$forder_upload.'/';?>'+path +'/'+ filename +'" style="width:120px;height:120px" alt="pic">');

        } catch (e) {

        };
    }

    $(document).ready(function(){
        $('#txtFileName').click(function(){
            $('input').prop('checked',false);
        });
    });

    loadBoxThongke();

    loadBoxKetQua();

    loadBoxTienIch();

    function loadBoxKetQua(){
        var url = "<?=$url->createUrl('home/boxketqua');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxketqua").html(msg);
            }
        });
    }

    function loadBoxTienIch(){
        var url = "<?=$url->createUrl('home/boxtienich');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxtienich").html(msg);
            }
        });
    }

    function loadBoxThongke(){
        var url = "<?=$url->createUrl('home/boxthongke');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxthongke").html(msg);
            }
        });
    }

    function register(){
        var username = $('#username').val();
        var password = $('#password').val();
        var confirm = $('#confirm').val();
        var mobile = $('#mobile').val();
        var picture = $('#picture').val();
        if($('#default1').prop('checked')==true){
            var radio = 'logo_avatar_acmilan.png';
        }
        if($('#default2').prop('checked')==true){
            var radio = 'logo_avatar_ars.png';
        }
        if($('#default3').prop('checked')==true){
            var radio = 'logo_avatar_barce.png';
        }
        if($('#default4').prop('checked')==true){
            var radio = 'logo_avatar_bayern.png';
        }
        if($('#default5').prop('checked')==true){
            var radio = 'logo_avatar_chese.png';
        }
        if($('#default6').prop('checked')==true){
            var radio = 'logo_avatar_real.png';
        }
        if($('#default7').prop('checked')==true){
            var radio = 'logo_avatar_mu.png';
        }
        if($('#default8').prop('checked')==true){
            var radio = 'logo_baby1.png';
        }
        if($('#default9').prop('checked')==true){
            var radio = 'logo_baby2.png';
        }
        if($('#default10').prop('checked')==true){
            var radio = 'logo_baby3.png';
        }
        if($('#default11').prop('checked')==true){
            var radio = 'logo_baby4.png';
        }
        if($('#default12').prop('checked')==true){
            var radio = 'logo_baby5.png';
        }
        if($('#default13').prop('checked')==true){
            var radio = 'logo_baby6.png';
        }
        if($('#default14').prop('checked')==true){
            var radio = 'logo_baby7.png';
        }
        if($('#default15').prop('checked')==true){
            var radio = 'logo_baby8.png';
        }
        if($('#default16').prop('checked')==true){
            var radio = 'logo_baby9.png';
        }
        if($('#default17').prop('checked')==true){
            var radio = 'logo_baby10.png';
        }
        if($('#default18').prop('checked')==true){
            var radio = 'logo_avatar_emotion1.png';
        }
        if($('#default19').prop('checked')==true){
            var radio = 'logo_avatar_emotion2.png';
        }
        if($('#default20').prop('checked')==true){
            var radio = 'logo_avatar_emotion3.png';
        }
        if($('#default21').prop('checked')==true){
            var radio = 'logo_avatar_emotion4.png';
        }
        if($('#default22').prop('checked')==true){
            var radio = 'logo_avatar_emotion5.png';
        }
        if($('#default23').prop('checked')==true){
            var radio = 'logo_avatar_emotion6.png';
        }
        if($('#default24').prop('checked')==true){
            var radio = 'logo_avatar_emotion7.png';
        }
        if($('#default25').prop('checked')==true){
            var radio = 'logo_avatar_emotion8.png';
        }
        if($('#default26').prop('checked')==true){
            var radio = 'logo_cunghoangdao1.png';
        }
        if($('#default27').prop('checked')==true){
            var radio = 'logo_cunghoangdao2.png';
        }
        if($('#default28').prop('checked')==true){
            var radio = 'logo_cunghoangdao3.png';
        }
        if($('#default29').prop('checked')==true){
            var radio = 'logo_cunghoangdao4.png';
        }
        if($('#default30').prop('checked')==true){
            var radio = 'logo_cunghoangdao5.png';
        }
        if($('#default31').prop('checked')==true){
            var radio = 'logo_cunghoangdao6.png';
        }
        if($('#default32').prop('checked')==true){
            var radio = 'logo_cunghoangdao7.png';
        }
        if($('#default33').prop('checked')==true){
            var radio = 'logo_cunghoangdao8.png';
        }
        if($('#default34').prop('checked')==true){
            var radio = 'logo_cunghoangdao9.png';
        }
        if($('#default35').prop('checked')==true){
            var radio = 'logo_cunghoangdao10.png';
        }
        if($('#default36').prop('checked')==true){
            var radio = 'logo_cunghoangdao11.png';
        }
        if($('#default37').prop('checked')==true){
            var radio = 'logo_cunghoangdao12.png';
        }
        var url = "<?=$url->createUrl('user/register');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                username: username,
                password: password,
                confirm: confirm,
                mobile: mobile,
                picture: picture,
                radio: radio,
            },
            success: function(msg){
                if(msg == 1){
                    alert('Bạn đã đăng ký thành công');
                    window.location = "<?php echo Yii::app()->createUrl('user/index')?>";
                }
                else{
                    $('#error').html(msg);
                }
            }
        });
    }
    
    function avatarBongDa(){
        var url = "<?=$url->createUrl('user/avatarbongda');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

    function avatarBaby(){
        var url = "<?=$url->createUrl('user/avatarbaby');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }
    
    function avatarEmotion(){
        var url = "<?=$url->createUrl('user/avataremotion');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }
    
    function avatarHoangDao(){
        var url = "<?=$url->createUrl('user/avatarhoangdao');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#avatar").html(msg);
            }
        });
    }

</script>

<div class="leftMain">
    <div class="titleCHAT">Đăng ký thành viên</div>
    <div class="SM">
        <table class="Login" width="100%" >
            <tr>
                <td width="25%"><b>Tên Đăng Nhập:</b></td>
                <td width="33%">
                    <input id="username" type="text" class="boxSearch" style="background: #fff;">&nbsp;<span class="red">(*)</span>
                </td>
                <td width="33%">

                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    <span style="font-size: 12px;">Tên đăng nhập nhỏ hơn 16 ký tự</span>
                </td>
                <td width="33%">

                </td>
            </tr>
            <tr>
                <td width="25%"><b>Mật khẩu:</b></td>
                <td width="33%">
                    <input id="password" type="password" class="boxSearch" style="background: #fff;">&nbsp;<span class="red">(*)</span>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    <span style="font-size: 12px;">Mật khẩu có nhiều hơn 6 ký tự và nhỏ hơn 25 ký tự</span>
                </td>
                <td width="33%">

                </td>
            </tr>
            <tr>
                <td width="25%"><b>Xác nhận mật khẩu:</b></td>
                <td width="33%">
                    <input id="confirm" type="password" class="boxSearch" style="background: #fff;">&nbsp;<span class="red">(*)</span>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    <span style="font-size: 12px;">Mật khẩu có nhiều hơn 6 ký tự và nhỏ hơn 25 ký tự</span>
                </td>
                <td width="33%">

                </td>
            </tr>
            <tr>
                <td width="25%"><b>Mobile:</b></td>
                <td width="33%">
                    <input id="mobile" type="text" class="boxSearch" style="background: #fff;">&nbsp;<span class="red">(*)</span>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%" style="padding: 0px 5px 0px 5px;">
                    <span style="font-size: 12px;">Lưu ý: nhập số mobile chính xác</span>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%" valign="top"><b>Avartar:</b></td>
                <td width="150%">
                    <div class="Avatar" id="avatar">
                        <ul>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_acmilan.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default1" type="radio">Default 1
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_ars.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default2" type="radio">Default 2
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_barce.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default3" type="radio">Default 3
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_bayern.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default4" type="radio">Default 4
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_chese.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default5" type="radio">Default 5
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_real.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default6" type="radio">Default 6
                            </li>
                            <li>
                                <img src="<?php echo Yii::app()->params['urlImages'];?>user/default/logo_avatar_mu.png" width="50" height="50" />
                                </br>
                                <input name="default" id="default6" type="radio">Default 7
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    <a href="javascript:void(0);" onclick="avatarBongDa();" class="button_KQ_2">Bóng đá</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" onclick="avatarBaby();" class="button_KQ_2">Baby</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" onclick="avatarEmotion();" class="button_KQ_2">Emotion</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" onclick="avatarHoangDao();" class="button_KQ_2">Cung Hoàng Đạo</a>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%" valign="top"><b>Upload:</b></td>
                <td width="150%" valign="top">

                    <input type="text" class="boxSearch" id="txtFileName" style="background: #fff; margin: 0px" readonly="readonly"/>&nbsp;<span class="red">(*)</span>
                    <!--<input type="text" id="urlFile" style="border:1px solid #DFDFDF; width: 200px;">-->
                    <span id="spanButtonPlaceHolder" style="margin-top: 5px;"></span>
                    <br/>
                    <!--<div class="fieldset flash" id="fsUploadProgress">
                    <span class="legend">File upload</span>
                    </div>-->
                    <input type="hidden" id="picture" value=""/>
                    <p id="show_pic"></p>

                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%" style="padding: 0px 5px 0px 5px;">
                    <span style="font-size: 12px;">Lưu ý: Bạn có thể đăng nhập qua tên hoặc số điện thoại</span>
                    </br>
                    <span class="error" id="error"></span>
                </td>
                <td width="33%">
                </td>
            </tr>
            <tr>
                <td width="25%"></td>
                <td width="33%">
                    </br>
                    <a href="javascript:void(0);" onclick="register();" class="button_KQ_1">Đăng ký</a>
                    &nbsp;
                    &nbsp;
                    <a href="javascript:void(0);" class="button_KQ_2">Làm lại</a>
                </td>
                <td width="33%">
                </td>
            </tr>
        </table>

    </div>
</div>
<div class="rightMain">
    <div class="Box" id="boxketqua"></div>

    <div class="Box" id="boxtienich"></div>

    <div class="Box" id="boxthongke"></div>
</div>
<div class="both"></div>